#include <stdio.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdbool.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <errno.h>

int main(int argc, char const *argv[])
{
    FILE *fp = fopen("config", "r");
    char *lib = calloc(1, 30);
    fgets(lib, 30, fp);
    fclose(fp);
    void *handle = dlopen(strtok(lib, "\n"), RTLD_NOW);
    if(handle == NULL){
        printf("加载动态库[%s]失败:%s\n", lib, strerror(errno));
        return 0;
    }
    void (*detect)(void);
    detect = dlsym(handle, "detection");
    if(detect == NULL){
        printf("查找符号[%s]失败:%s\n", "detection", strerror(errno));
        return 0;
    }
    detect();
    dlclose(handle);
    return 0;
}
